Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Types of Attributes and Attribute Sets

QuickDraw 3D defines a large number of basic attribute types, which represent information such as surface color, transparency, parameterization, normal, tangent, and so forth. In addition, if the basic QuickDraw 3D attribute types are not sufficient for the needs of your application, you can define custom attribute types. For example, you might want to maintain information about the temperature over time of each point on the surface of an object. To do so, you can define a new attribute type and a data structure to hold the relevant information. You also need to define an attribute metahandler, which contains methods for handling your custom attribute data. (QuickDraw 3D defines metahandlers for all the basic attribute types.)

The basic attributes types are defined by constants. See "Attribute Types" for a complete description of these attribute types.

typedef enum TQ3AttributeTypes {
    kQ3AttributeTypeNone                                            = 0,
    kQ3AttributeTypeSurfaceUV                                       = 1,
    kQ3AttributeTypeShadingUV                                       = 2,
    kQ3AttributeTypeNormal                                          = 3,
    kQ3AttributeTypeAmbientCoefficient                              = 4,
    kQ3AttributeTypeDiffuseColor                                    = 5,
    kQ3AttributeTypeSpecularColor                                   = 6,
    kQ3AttributeTypeSpecularControl                                 = 7,
    kQ3AttributeTypeTransparencyColor                               = 8,
    kQ3AttributeTypeSurfaceTangent                                  = 9,
    kQ3AttributeTypeHighlightState                                  = 10,
    kQ3AttributeTypeSurfaceShader                                   = 11,
    kQ3AttributeTypeNumTypes
} TQ3AttributeTypes;

You can attach a set of attributes to a view, to a group of objects, to a single geometric object, to a face of an object, or to a vertex of an object. In addition, you can attach edge and corner attributes to meshes. For each of these levels, QuickDraw 3D defines a set of natural attributes. For example, the surface normal attribute (which defines the normal vector at a point) makes no sense when applied to a view or a nonpolygonal geometric object. It does, however, make sense to include the surface normal attribute in a set of face or vertex attributes. Accordingly, the surface normal attribute is contained in the natural sets of attributes for faces and vertices, but not for views, groups, or nonpolygonal geometric objects. Table 5-1 lists the natural attributes that can be assigned to objects in the QuickDraw 3D object hierarchy.

You can, if you wish, include in the attribute set of any kind of object attributes that are not natural to that object. For instance, you can put a surface normal attribute into an attribute set attached to a view. You can then access that unnatural attribute in precisely the same way you access any other attribute in the set. The only difference between natural and unnatural attributes is that unnatural attributes in an attribute set are not inherited by objects lower down in the class hierarchy. See "Attribute Inheritance" for details.

Table 5-1 Natural sets of attributes for objects in a hierarchy

Object type

Natural attributes in the set

View object
Group object
Geometric object
Face

kQ3AttributeTypeAmbientCoefficient
kQ3AttributeTypeDiffuseColor
kQ3AttributeTypeSpecularColor
kQ3AttributeTypeSpecularControl
kQ3AttributeTypeTransparencyColor
kQ3AttributeTypeHighlightState
kQ3AttributeTypeSurfaceShader

Vertex

kQ3AttributeTypeSurfaceUV
kQ3AttributeTypeShadingUV
kQ3AttributeTypeNormal
kQ3AttributeTypeAmbientCoefficient
kQ3AttributeTypeDiffuseColor
kQ3AttributeTypeSpecularColor
kQ3AttributeTypeSpecularControl
kQ3AttributeTypeTransparencyColor
kQ3AttributeTypeSurfaceTangent

Surface normals assigned to faces are ignored by renderers, as are the surface normals that are computed geometrically from the points that make up the face.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |